package com.shiguiwu.springboot3.filter;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.delete.Delete;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @description: 删除操作
 * @author: stone
 * @date: Created by 2023/7/21 20:42
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.filter
 */
@Component
@Slf4j
public class DeleteFilter extends AbstractSqlFilter {

    @Override
    public boolean isSupport() {
        return this.getStatement() instanceof Delete;
    }

    @Override
    public void handleSql(Set<String> cols) {
        Delete delete = (Delete) this.getStatement();
        Table table = delete.getTable();

        log.warn("删除的表名 ==> {}", table.getName());
        cols.add(table.getName());

        this.handleWhere(cols, delete.getWhere());
    }

}
